const Koa= require('koa')
const app = new Koa()


const middleware = async function  (ctx,next) {
    console.log('this is a middleware!')
    console.log(ctx.request.path)
    next()
}
const middleware2 = async function  (ctx,next) {
    console.log('this is a middleware2!')
    console.log(ctx.request.path)
    next()//按照底下app.use的顺序执行下一个模块
    console.log('this is a middleware2 end!')//所有模块全部执行完毕后它再按顺序执行next后面的代码

}
const middleware3 = async function  (ctx,next) {
    console.log('this is a middleware3!')
    console.log(ctx.request.path)
    next()
    console.log('this is a middleware3 end!')
}

app.use(middleware)
app.use(middleware2)
app.use(middleware3)
app.listen(3000)